var utils = require('../../../../utils/util.js') 
Page({
    data: {
        user_name:'',
        bank_no:''
    },
    onShow: function () {
        utils.checkLogin();
        var name = wx.getStorageSync("userinfo").name;
        if (name!='') {
            this.setData({
                user_name:name
            });
        }
    },
    bankname:function(e){
        this.setData({
          user_name: e.detail.value
        })
    },
    banknumber:function(e){
        this.setData({
          bank_no: e.detail.value
        })
    },
    //下一步
    setbank: function () {
        var that = this;
        var token = wx.getStorageSync("userinfo").wap_token;
        var user_name = this.data.user_name;
        if (user_name=='') {
            wx.showToast({
                title: '请先去个人中心完善资料',
                icon: 'none',
                duration: 1500
            });
            setTimeout(function(){
                wx.navigateTo({
                    url: "/pages/my/editself/settruename/index",
                })
            }, 1000);
            return false;
        }
        var bank_no = this.data.bank_no;
        var data = {
          url: "/v1/userbank/getBankInfo",
          token: token,
          bank_no: bank_no
        };
        utils.request(data).then(function (res) {
            if (res.code == 0) {
                var url = '/pages/my/bank/confirm/index?user_name='+user_name+'&bank_no='+bank_no+'&bank_name='+res.data.bak+'&bank_type='+res.data.type;
                wx.navigateTo({
                    url: url,
                })
            }else{
                wx.showToast({
                    title: res.msg,
                    icon: 'none',
                    duration: 1500
                })
            }
        });
    },
})